<template>
  <div>
    <a-input  v-if="!value.predicateName" style="width: 100%" @change="onChange" v-model="args"></a-input>
    <a-input v-else v-model="args" @change="onChange" :placeholder="i18n('predicate.path','路径')"></a-input>
  </div>
</template>

<script>
  export default {
    name: "PathEdit",
    props: ["value"],
    data() {
      return {
        args:""
      }
    },
    created() {
      this.init();
    },
    methods: {
      i18n(name,text,key){
          return this.$ti18(name,text,"SysRouting",key);
      },
      init() {
        if (this.value.predicateArgs == "") {
          this.args = "";
        } else {
          this.args = (JSON.parse(this.value.predicateArgs))._genkey_0;
        }
      },
      onChange(){
        if(!this.value.predicateName){
            this.$message.warning(this.i18n('msa.predicateTips','条件名称不能为空'));
          this.args="";
        }else {
          var obj={
            _genkey_0:this.args,
          };
          this.value.predicateArgs=JSON.stringify(obj);
        }
      }
    },
  }
</script>

<style scoped>

</style>